package thread;

public class ThreadDemo18 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() ->{
            for (int i = 0; i < 1000; i++) {
//                System.out.println("线程运行中----");
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        //线程启动之前,状态就是NEW
        System.out.println(t.getState());
        t.start();
        System.out.println(t.getState());//RUNNABLE
        Thread.sleep(500);//确保进入t的sleep
        System.out.println(t.getState());//TIMED_WAITING
        t.join();
        //线程运行完之后,状态就是TERMINATED
        System.out.println(t.getState());

    }
}
